#pragma once

#include <string>
#include <memory>
#include <unordered_map>
#include <functional>
#include <set>

#include "GcovTypeDefine.hpp"
#include "WriteExcel_base.hpp"

namespace gcov
{
    enum GcovVersion
    {
        GCOV_VERSION_0 = 0,
        GCOV_VERSION_1 = 1,
        GCOV_VERSION_2 = 2,
        GCOV_VERSION_14 = 14,
        GCOV_VERSION_15 = 15,
    };

    using GcovMajorVersion = GcovVersion;
    using GcovMinorVersion = GcovVersion;

    class IGcov
    {
    public:
        virtual ~IGcov() {}
        virtual std::shared_ptr<wxlsx::ExcelUtInfoList> readXmlGcov(std::string xmlFilePath, std::string gcovFilePat) = 0;
    };

    class GcovManager
    {
    private:
        GcovMajorVersion m_majorVersion;
        GcovMinorVersion m_minorVersion;
        std::string m_version;
        std::shared_ptr<IGcov> m_currentGcov;

        bool isXml(std::string &xmlFilePath);
        std::string makeStringVersion(GcovMajorVersion majorVersion, GcovMinorVersion minorVersion) const;

    public:
        GcovManager(GcovMajorVersion majorVersion, GcovMinorVersion minorVersion);
        virtual ~GcovManager();
        std::string getVersion() const;
        /**
         * @brief 如果filePath是无效的路径，则返回nullptr;
         *
         * @param filePath gcov的相对/绝对路径
         */
        std::shared_ptr<wxlsx::ExcelUtInfoList> readXmlGcov(std::string xmlFilePath, std::string gcovFilePath);
    };
} // namespace gcov
